CHARTS
Photo by Jorge Zapata on Unsplash
If your mother cooks Italian food, why should you go to a restaurant?
— Martin Scorsese, Director
A study published in the the Journal of Cultural Economics, Dining out as cultural trade, used data from TripAdvisor to examine restaurant cuisines, combined with Euromonitor data on overall and fast-food expenditure. The paper calculated the implicit trade patterns in global cuisines for 52 destination countries. The research was presented in a Daily Chart segment of the Economist using a bar chart with divergent values. The chart is designed to reveal how domestic and foreign food consumption profiles can identify which countries have the greatest influence on the world’s cuisine preferences.
# Load data
df_exports <- read.csv("archetypes/world-cuisine-preferences/table-6-cuisine-net-exports-excluding-fast-food.csv", header = TRUE, stringsAsFactors = FALSE)
df_exports
df_fast_food <- read.csv("archetypes/world-cuisine-preferences/table-6-cuisine-net-exports-including-fast-food.csv", header = TRUE, stringsAsFactors = FALSE)
df_fast_food
# Cast column type
df_exports$Exports <- as.numeric(gsub(",", "", df_exports$Exports))
df_exports$Imports <- as.numeric(gsub(",", "", df_exports$Imports))
# Cast column type
df_fast_food$Exports <- as.numeric(gsub(",", "", df_fast_food$Exports))
df_fast_food$Imports <- as.numeric(gsub(",", "", df_fast_food$Imports))
# Calculate the net exports and fill in the fourth column
df_exports$Net.exports <- df_exports$Exports-df_exports$Imports
df_fast_food$Net.exports <- df_fast_food$Exports-df_fast_food$Imports
# Remove all missing data
df_exports <- df_exports %>% filter(Net.exports!='NA')
df_fast_food <-df_fast_food %>% filter(Net.exports!='NA')
# Change order of factors to sort from highest to lowest
df_exports <- df_exports %>% mutate(Country = factor(Country))
df_exports$Country <- fct_reorder(df_exports$Country, df_exports$Net.exports, max)
df_fast_food <- df_fast_food %>% mutate(Country = factor(Country))
df_fast_food$Country <- fct_reorder(df_fast_food$Country, df_fast_food$Net.exports, max)
# Make colors based on value threshold
df_exports$Color <- ifelse(df_exports$Net.exports > 0, "Exporter", "Importer")
df_exports <- df_exports %>% mutate(Color = factor(Color))
df_fast_food$Color <- ifelse(df_fast_food$Net.exports > 0, "Exporter", "Importer")
df_fast_food <- df_fast_food %>% mutate(Color = factor(Color))
# Filter df into two parts for labels later
df_exports_l <- df_exports %>% filter( df_exports$Net.exports > 0 )
df_exports_r <- df_exports %>% filter( df_exports$Net.exports < 0 )
df_fast_food_l <- df_fast_food %>% filter( df_fast_food$Net.exports > 0 )
df_fast_food_r <- df_fast_food %>% filter( df_fast_food$Net.exports < 0 )
df_exports
df_fast_food
# Make the plot
v1 <- ggplot( df_exports, aes( x = Net.exports, y = Country, fill = Color ) ) +
geom_bar(stat = "identity") +
scale_fill_manual(values = color_palette) +
# Country Label
geom_text( data = df_exports_l, size = 4, label = df_exports_l$Country, x = -110, y = df_exports_l$Country, hjust = 1, color = 'gray30' ) +
geom_text( data = df_exports_r, size = 4, label = df_exports_r$Country, x = 200, y = df_exports_r$Country, hjust = 0, color= 'gray30' ) +
# Value Label
geom_text( data = df_exports_l, size = 4, label = df_exports_l$Net.exports, hjust = 0, position = position_nudge(x = 125), color = 'gray30') +
geom_text( data = df_exports_r, size = 4, label = df_exports_r$Net.exports, hjust = 1, position = position_nudge(x = -125), color = 'gray30') +
# Manual Annotations
annotate( geom = "text", x = 51000, y = 'Turkey', label = 'Net\nExporters', color = "#076fa1", size = 6, hjust = 0) +
annotate( geom = "text", x = -51000, y = 'Australia' , label = 'Net\nImporters', color = "#2fc1d3", size = 6, hjust = 1) +
# Red Line
geom_vline( xintercept = 0, colour = "red", linetype = "solid", size = 1.1 ) +
# Top Axis
scale_x_continuous(limits = c(-150000, 175000), breaks=seq(-150000,175000, 25000), sec.axis = dup_axis()) +
# Title and Caption
labs(title = "Unbalanced diets", subtitle = "Cuisine Net Exports Excluding Fast Food") +
#labs()+
theme_minimal() +
theme_opts
girafe(ggobj = v1, width_svg = 1280/72, height_svg = 720/72,
options = list(opts_sizing(rescale = TRUE, width = 1.0))
)
# Make the plot
v2 <- ggplot( df_fast_food, aes( x = Net.exports, y = Country, fill = Color ) ) +
geom_bar(stat = "identity") +
scale_fill_manual(values = color_palette) +
# Country Label
geom_text( data = df_fast_food_l, size = 4, label = df_fast_food_l$Country, x = -110, y = df_fast_food_l$Country, hjust = 1, color = 'gray30' ) +
geom_text( data = df_fast_food_r, size = 4, label = df_fast_food_r$Country, x = 200, y = df_fast_food_r$Country, hjust = 0, color= 'gray30' ) +
# Value Label
geom_text( data = df_fast_food_l, size = 4, label = df_fast_food_l$Net.exports, x = df_fast_food_l$Net.exports, y = df_fast_food_l$Country, hjust = 0, position = position_nudge(x = 125), color = 'gray30') +
geom_text( data = df_fast_food_r, size = 4, label = df_fast_food_r$Net.exports, x = df_fast_food_r$Net.exports, y = df_fast_food_r$Country, hjust = 1, position = position_nudge(x = -125), color = 'gray30') +
# Manual Annotations
annotate( geom = "text", x = 51000, y = 'France', label = 'Net\nExporters', color = "#076fa1", size = 6, hjust = 0) +
annotate( geom = "text", x = -51000, y = 'Australia' , label = 'Net\nImporters', color = "#2fc1d3", size = 6, hjust = 1) +
# Red Line
geom_vline( xintercept = 0, colour = "red", linetype = "solid", size = 1.1 ) +
# Top Axis
scale_x_continuous(limits = c(-75000, 175000), breaks=seq(-75000,175000, 25000), sec.axis = dup_axis()) +
# Title and Caption
labs(title = "Unbalanced diets", subtitle = "Cuisine Net Exports Including Fast Food ($bn)") +
theme_minimal() +
theme_opts
girafe(ggobj = v2, width_svg = 1280/72, height_svg = 720/72,
options = list(opts_sizing(rescale = TRUE, width = 1.0))
)
## [1] T. Economist. _Which countries dominate the world’s dinner
## tables?_ The Economist, Aug. 2019. <URL:
## https://www.economist.com/graphic-detail/2019/08/23/which-countries-dominate-the-worlds-dinner-tables>
## (visited on 02/15/2021).
##
## [2] J. Waldfogel and N. B. O. E. Research. _Dining out as cultural
## trade_. National Bureau Of Economic Research, 2019.